function main() {
    debugger;
    const self = this;
    const fileName = self.$$("text_input_9nadmq").cValue;
    self.isLoading = true;

    if (!fileName) {
        self.$message.warning("请填写视频名称！");
        self.isLoading = false;
        return;
    }

    const inputEle = window.INPUELEMENT;
    if (!inputEle || inputEle === "") {
        self.$message.warning("请上传视频！");
        self.isLoading = false;
        return;
    }

    const file = inputEle.files[0];

    if (!file) {
        self.$message.warning("请上传视频！");
        self.isLoading = false;
        return;
    }

    // 上传视频
    uploadVideo(file, fileName).then(res => {
        self.isLoading = false;
        closeMingJingDialog();
    }).catch(err => {
        self.isLoading = false;
        self.$message.error("视频上传失败，请重试！");
        console.error(err);
    });
}


function uploadVideo(fileValue, fileNameValue) {
    const formData = new FormData();

    formData.append('file', fileValue);
    formData.append('fileName', fileNameValue);


    const formParams = [
        {name: "file", type: "FormData", valueType: "FILE", valueContent: fileValue},
        {name: "fileName", type: "FormData", valueContent: fileNameValue}
    ];

    return new Promise((resolve, reject) => {
        api.DATA_SOURCE_EXECUTE("741ac3c4-fcd8-4ac1-b1fe-89c29ac4bcdf", "api", [], formParams, "", formData).then((res) => {
            resolve(res);
        }).catch((err) => {
            reject(err); // 上传失败时返回错误
        });
    });
}


function closeMingJingDialog() {
    if (window) {
        window.postMessage(JSON.stringify({
            event: "close-dialog",
            param: {"XXX": "test"}
        }), "*");
    }
}
